package com.bwie.behavior.controller;

import java.util.Arrays;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bwie.behavior.entity.AppointmentEntity;
import com.bwie.behavior.service.AppointmentService;
import com.bwie.common.utils.PageUtils;
import com.bwie.common.utils.R;



/**
 * 
 *
 * @author wangguohai
 * @email 270901876@qq.com
 * @date 2022-04-21 20:45:08
 */
@RestController
@RequestMapping("behavior/appointment")
public class AppointmentController {
    @Autowired
    private AppointmentService appointmentService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = appointmentService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{appointmentId}")
    public R info(@PathVariable("appointmentId") Integer appointmentId){
		AppointmentEntity appointment = appointmentService.getById(appointmentId);

        return R.ok().put("appointment", appointment);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody AppointmentEntity appointment){
		appointmentService.save(appointment);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody AppointmentEntity appointment){
		appointmentService.updateById(appointment);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] appointmentIds){
		appointmentService.removeByIds(Arrays.asList(appointmentIds));

        return R.ok();
    }

}
